import QtQuick 1.1
import QtMultimediaKit 1.1
import com.nokia.symbian 1.1
import "core/Constants.js" as Constant
import "core/userSettings.js" as UserSettings
Window {
    id: window
    anchors.fill: parent
    property real backgroundVolume: 0.25
    property real soundVolume: 0.25
    PageStack{
        id:pageStack
        initialPage: splashScreen
        toolBar: sharedToolBar
        anchors {
            left: parent.left
            right: parent.right
            top: parent.top
            bottom: parent.bottom
        }
    }

    StatusBar {
        id: statusBar

        anchors { top: parent.top; left: parent.left; right: parent.right }
    }

    ToolBar {
        id: sharedToolBar
        anchors { bottom: parent.bottom; left: parent.left; right: parent.right }
    }


    MenuPage{
        id: menuPage
        anchors { fill: parent; topMargin: statusBar.height; bottomMargin: sharedToolBar.height }
        tools:ToolBarLayout{
            ToolButton{
                iconSource:  "toolbar-back"
                onClicked: {
                    UserSettings.saveGameSettings();
                    Qt.quit();
                }
            }
        }
    }

    ScorePage{
        id: scorePage
        anchors { fill: parent; topMargin: statusBar.height; bottomMargin: sharedToolBar.height }
        tools:ToolBarLayout{
            ToolButton{
                iconSource:  "toolbar-back"
                onClicked: pageStack.replace(menuPage);
            }
        }
    }

    GamePage{
        id: gamePage
        anchors { fill: parent; topMargin: statusBar.height; bottomMargin: sharedToolBar.height }
        tools:ToolBarLayout{
            ToolButton{
                iconSource:  "toolbar-back"
                onClicked: {
                    pageStack.replace(menuPage);
                    gamePage.saveGame = true;
                }
            }
        }
    }

    OptionPage{
        id: optionPage
        anchors { fill: parent; topMargin: statusBar.height; bottomMargin: sharedToolBar.height }
        tools:ToolBarLayout{
            ToolButton{
                //text:"back"
                iconSource:  "toolbar-back"
                onClicked: pageStack.replace(menuPage);
            }
        }
    }

    HelpPage{
        id:helpPage
        anchors { fill: parent; topMargin: statusBar.height; bottomMargin: sharedToolBar.height }
        tools:ToolBarLayout{
            ToolButton{
                //text:"back"
                iconSource:  "toolbar-back"
                onClicked: pageStack.replace(menuPage);
            }
        }
    }

    AboutPage{
        id: aboutPage
        anchors { fill: parent; topMargin: statusBar.height; bottomMargin: sharedToolBar.height }
        tools:ToolBarLayout{
            ToolButton{
                //text:"back"
                iconSource:  "toolbar-back"
                onClicked: pageStack.replace(menuPage);
            }
        }
    }
    Audio {
        id: musicPlayer
        volume: backgroundVolume
        source: "sound/background.wav"
        autoLoad: false
        onStopped: musicPlayer.play();
    }
    SplashScreen{
        id: splashScreen
        anchors.fill: parent
    }
    Component.onCompleted: {
        UserSettings.loadGameSetting();
        musicPlayer.play();
    }
}
